This is length-sensitive extension to the filter-harmonize2. It enables to give also length patterns associated to two input melodies. len-harmonize2 has two outputs which must be bound to atoms using multiple-value-setq.
(setq mel1 '(a b c d a b c d a b c d a b c d))
(setq mel2 '(a b d b e b f b b e b b d b b a s g))
(setq len1 '(1/16 1/8 1/16 1/4))
(setq len2 '(1/16))
(multiple-value-setq (hmel1 hmel2)
(len-harmonize2 mel1 len1 mel2 len2
12
'1/1
(activate-tonality (harmonic-minor c 2))
'((4 4))
'((1 2 6 8 10 11))))
hmel1 --> (a b c = a b c d)
hmel2 --> (a b d = e b f b = e b = d b b a)
Note that the zone controls how long the length patterns are to be run, and controls the recycling of the input patterns when necessary. Try with different zone lengths to get the effect.
After harmonisation it is often needed to smooth out the output a bit with find-change and filter-deactivate. Also symbol-fold can be handy in keeping the material more consistent. These are needed mostly when you don't exactly know beforehand what the input melodies are, if they have lots of repeats, or are in wide range of symbols.
len-harmonize2 performs its operation with the aid of expand-with-len and compress-with-len. These functions can be useful in other purposes, too.
expand-with-len takes a symbol pattern, length pattern, zone length and the minimum length (minimum quantisation value). The result is a symbol pattern which is expanded using the rhythm to last the zone using the minimum length to determine the number of repeats of each symbol.
(expand-with-len '(a b c d) '(1/16. 1/8) '1/1 '1/32)
--> (a a a b b b b c c c d d d d a a a b b b b c c c d d d d a a a b b b b)
compress-with-len takes a symbol pattern, length pattern and minimum length and picks up the right symbols that match the rhythm.
(compress-with-len (expand-with-len '(a b c d) '(1/16. 1/8) '1/1 '1/32)